package com.lbh.config;


import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.ext.handler.ContextPathHandler;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;
import com.lbh.controller.ThreeController;
import com.lbh.model.JobModel;
import com.lbh.quartz.QuartzPlugin;

public class QJConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		PropKit.use("dev.properties");
		me.setDevMode(true);
		me.setViewType(ViewType.FREE_MARKER);
		 me.setBaseViewPath("/WEB-INF/view/");
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/three", ThreeController.class,"/");
	}

	@Override
	public void configPlugin(Plugins me) {
		boolean flog = false;
		C3p0Plugin c3p0 = new C3p0Plugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password").trim());
		me.add(c3p0);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0);
		arp.addMapping("job", JobModel.class);
		me.add(arp);
		// 这是自己封装的 不是导的包！！
		QuartzPlugin qu = null;
		if (flog)
			qu = new QuartzPlugin("job.properties", "quartz.properties");// 本地缓存
		else
			qu = new QuartzPlugin("jobdb.properties","quartzdb.properties");// 数据库
		
		me.add(qu);
		
		
	}

	@Override
	public void configInterceptor(Interceptors me) {
	}

	@Override
	public void configHandler(Handlers me) {
		me.add(new ContextPathHandler("base"));
	}

}
